package com.dao;

import java.util.List;
import java.util.Map;
import com.servlet.My;
import hyl.core.MyFun;
import hyl.core.db.MyDB;

public class SqlOfUser {

	// 读取用户信息
	public static Map<String, Object> login(String name, String pass) {
		// 最多保留10个备份
		String sql = "select a.id,a.tjrid,a.uname,a.uphone,a.roleid,a.istate,a.ualias from user a left join user_conf b on a.id=b.id where  a.istate!=0 and a.uname =? and a.upass=? ";
		Object[] params = { name, pass };
		MyDB db = My.getDB1();
		return db.queryMap(sql, params);
	}

	public static int get_随机id() {
		int uuid = (int) (Math.random() * (99999999 - 10000000) + 10000000);
		MyDB db = My.getDB1();
		String sql = "select * from user where uname=?";
		Object[] param = {uuid};
		List<Map<String,Object>> list = db.queryList(sql, param);
		if (list.size() > 0) {
			get_随机id();
		}
		return uuid;
	}
	
	//查询用户id
	public static Integer cid(Object[] obj) {
		MyDB db = My.getDB1();
		String sql = "select id from user where id=? or uname=?  ";
		Object ob = db.querySingle(sql, obj);
	
		return MyFun.obj2Int(ob);
	}
	
}
